#pragma once

#include "../LMCommon.h"
#include <boost/asio.hpp>
#include <boost/thread.hpp>
#include <boost/smart_ptr.hpp>
#include "../xpt/xptServer.h"
#include "../proto/workitem.pb.h"

class LMMaster;
class LMWorkerProxy
{
public:
	LMWorkerProxy(boost::shared_ptr<boost::asio::ip::tcp::socket> socket, LMMaster* master);
	~LMWorkerProxy();

	bool isOnline();
	void start();
	void updateWork(ProtoXptBlockWorkInfo *work);

protected:
	void workThread();

protected:
	boost::mutex _socketMutex;
	boost::shared_ptr<boost::asio::ip::tcp::socket> _socket;
	LMMaster* _master;
	boost::shared_ptr<boost::thread> _workThr;
};